﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;
using GestionEco;

namespace Ecosystème
{
    public class Serialiser
    {
        XmlSerializer xs;
        List<EtreVivant> liste;
        String cheminXMLsave = "C:\\Users\\adrien\\Desktop\\save.xml";

        public void serialiserEtat(List<EtreVivant> listeEV)
        {
            //liste = new List<EtreVivant>(listeEV.Count);

            xs = new XmlSerializer(typeof(List<EtreVivant>)); //pb attribut protected dans EV
            StreamWriter writer = new StreamWriter(cheminXMLsave);

            xs.Serialize(writer, listeEV);

            writer.Close();
        }

        public List<EtreVivant> deserialiserEtat()
        {
            StreamReader reader = new StreamReader(cheminXMLsave);

            List<EtreVivant> listeEV = (List<EtreVivant>)xs.Deserialize(reader);

            reader.Close();
            return listeEV;
        }
    }
}
